<template>
  <div>
    <div class="app-container">
      <mt-header fixed :title="data.name">
        <router-link slot="left" to="">
          <mt-button icon="back" @click.native="$router.back(-1)">
            返回
          </mt-button>
        </router-link>
      </mt-header>

      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <el-row :gutter="20">
        <el-col :span="8"> &nbsp;</el-col>
        <el-col :span="8">
          <div align="center">
            <img :src="data.image" width="40" height="40" />
          </div>
        </el-col>
        <el-col :span="8">
          <mt-button
            v-if="data.channel"
            size="small"
            class="el-icon-chat-dot-square"
            @click.native="handleGo"
          >
            去咨询
          </mt-button>

          <mt-button
            v-else
            size="small"
            class="el-icon-plus"
            @click.native="handlePlus"
          >
            关注
          </mt-button>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6"> &nbsp;</el-col>
        <el-col :span="6">
          <div align="right">
            {{ data.name }}
          </div>
        </el-col>
        <el-col :span="6"> {{ data.title__name }} </el-col>
        <el-col :span="6"> &nbsp;</el-col>
      </el-row>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div align="center">
        {{ data.comment }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PartnerEmployee',
  components: {},
  directives: {},
  filters: {},
  props: {},

  data() {
    return {
      chatPath: '/app/mail/chat',
      currentRow: {}
    }
  },
  computed: {
    data: function() {
      return this.$store.state.appPartnerEmployee.dataDict
    }
  },
  async created() {
    const { id } = this.$route.query
    this.$store.dispatch('appPartnerEmployee/browse_one', { id })
  },

  methods: {
    async handleGo() {
      this.$router.push({
        path: this.chatPath,
        query: { id: this.data.channel.id }
      })
    },
    async handlePlus() {
      await this.$store.dispatch('appPartnerEmployee/channel_get', {
        id: this.data.id
      })

      this.$message({
        message: '关注成功, 可以去咨询了',
        type: 'success'
      })
    }
  }
}
</script>

<style type="text/css"></style>
